FROM alpine:3.11

ENV LANG=C.UTF-8 \
TZ=Asia/Shanghai \
NFS_SERVER_ADDRESS=192.168.1.99 \
NFS_SERVER_EXPOSED_PATH=/opt/nfs/datasets \
FILE_FOLDER_ROOT=/var/lib/data-set-api/datasets \
FILE_SERVER_PREFIX=https://192.168.2.254:65534/ \
SQLALCHEMY_DATABASE_URI=sqlite:////var/lib/data-set-api/db.sqlite3

COPY . /opt/data-set-api

WORKDIR /opt/data-set-api

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.huaweicloud.com/' /etc/apk/repositories && \
apk --no-cache update && apk --no-cache upgrade && \
apk add --no-cache tzdata python3 && \
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo $'[global]\n\
index-url = https://mirrors.huaweicloud.com/repository/pypi/simple\n\
trusted-host = mirrors.huaweicloud.com\n\
timeout = 120\n\
' > /etc/pip.conf && \
pip3 --no-cache-dir install --upgrade pip && \
pip3 --no-cache-dir install -r requirements.txt

EXPOSE 65535

VOLUME /var/lib/data-set-api

ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:65535", \
"--access-logfile", "-", "--disable-redirect-access-to-syslog", \
"--workers", "2", "--threads", "2", \
"--certfile", "certs/cert.pem", \
"--keyfile", "certs/key.pem", \
"data_set_api.main:server"]
